var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  a = require("../../../utils/http.js"),
  e = t(require("../../../utils/util")),
  s = new a.HTTP;
Page({
  data: {
    zhongdian: !0,
    previousPage: 1,
    total: 1,
    kehu: !0,
    listDay: e.default.formatDay(new Date),
    listMonth: e.default.formatDates(new Date),
    showStatus:false,
    radio: '1',
    message:'',
    title:'请假'
  },
  onClose(e){
    this.setData({
      message:'',
      radio:'1',
      title:'请假',
      showStatus:!this.data.showStatus
    })
  },
  openStatus(e){
    this.setData({
      showStatus:!this.data.showStatus
    })
  },
  onClick(event){
    const { name,title } = event.currentTarget.dataset;
    this.setData({
      radio: name,
      title,
    });
    if (name == '1' || name == '2') {
      this.setData({
        message:''
      })
    }
  },
  onChange(e){
    this.setData({
      message:e.detail
    })
  },
  onSubmit(){
    let that = this
    let user = wx.getStorageSync('user')
    if (that.data.radio != '1' && that.data.radio != '2') {
      if (that.data.message == '') {
        return wx.showToast({
          title: '请填写未跟进原因',
          duration:1000,
          icon:'none'
        })
      }
      
      if (that.data.message.length > 20) {
        return wx.showToast({
          title: '具体原因不超过20个字',
          duration:1000,
          icon:'none'
        })
      }
    }
    
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: 'https://www.qlsyyun.com:3030/report/status',
      method:"POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data:{
        zsy:user[0],
        nf:new Date().getFullYear(),
        yf:new Date().getMonth() + 1,
        df:new Date().getDate(),
        gs:this.data.title,
        nb:this.data.message
      },
      success(res){
        wx.hideLoading()
        that.onClose()
      },
    })
    
  },
 
  onLoad: function (t) {
    var a = wx.getStorageSync("user");
    let that = this
    if (t.id == 9) {
      wx.request({
        url: `https://www.qlsyyun.com:3000/newPages/getPfid?name=${a[0]}&bm=${a[1]}`,
        method:'GET',
        success({data}){
          console.log(data)
          wx.request({
            url: `https://www.qlsyyun.com:3000/newPages/getBindList?pfid=${data.data[0].pfid}`,
            method:'GET',
            success({data}){
              that.setData({
                externalCustomerList:data.data
              })
            }
          })
        },
      })
    }
    wx.setNavigationBarTitle({
      title: t.address,
      id: t.id
    });
  
    that.setData({
        id: t.id,
        user: a
      }),
      2 == t.id ? that.purpose() : 3 == t.id ? that.mycustom() : 4 == t.id ? that.stress() : 5 == t.id ? that.ocean() : 7 == t.id ? that.takeNote() : that.contacts()
  },
  purpose: function () {
    var t = this;
    t.data.user[4] < 9 ? s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 6,
        yxxm: t.data.user[1]
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 6,
            total: t.data.total,
            yxxm: t.data.user[1]
          }
        }).then((function (a) {
          t.setData({
            clients: a.data
          })
        }))
    })) : s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 1
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 1,
            total: t.data.total
          }
        }).then((function (a) {
          t.setData({
            clients: a.data
          })
        }))
    }))
  },
  mycustom: function () {
    var t = this;
    s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 12,
        name: t.data.user[0]
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 12,
            total: t.data.total,
            name: t.data.user[0]
          }
        }).then((function (a) {
          0 == a.data.length ? t.setData({
            kehu: !1
          }) : t.setData({
            customers: a.data
          })
        }))
    }))
  },
  stress: function () {
    var t = this;
    6 == t.data.user[4] ? s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 7,
        yxxm: t.data.user[1]
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 7,
            total: t.data.total,
            yxxm: t.data.user[1]
          }
        }).then((function (a) {
          t.setData({
            customers: a.data
          })
        }))
    })) : t.data.user[4] < 6 ? s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 8,
        name: t.data.user[0]
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 8,
            total: t.data.total,
            name: t.data.user[0]
          }
        }).then((function (a) {
          0 == a.data.length ? t.setData({
            zhongdian: !1
          }) : t.setData({
            customers: a.data
          })
        }))
    })) : s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 2
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 2,
            total: t.data.total
          }
        }).then((function (a) {
          t.setData({
            customers: a.data
          })
        }))
    }))
  },
  ocean: function () {
    var t = this;
    s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 3
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 3,
            total: t.data.total
          }
        }).then((function (a) {
          t.setData({
            gain: a.data
          })
        }))
    }))
  },
  datelist: function () {
    var t = this;
    s.request({
        url: "https://www.qlsyyun.com:3030/list",
        data: {
          arr: 3,
          name: t.data.user[0],
          listDay: t.data.listDay
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          todatVisit: 0
        }) : t.setData({
          todatVisit: a.data[0].ztb
        })
      })),
      s.request({
        url: "https://www.qlsyyun.com:3030/list",
        data: {
          arr: 4,
          name: t.data.user[0],
          listMonth: t.data.listMonth
        }
      }).then((function (a) {
        0 == a.data.length ? t.setData({
          monthVisit: 0
        }) : t.setData({
          monthVisit: a.data[0].ztb
        })
      }))
  },
  lastDay: function (t) {
    var a = t.currentTarget.dataset.id;
    1 == a && this.data.listDay > 1 ? (this.setData({
      listDay: this.data.listDay - 1
    }), this.datelist()) : 3 == a && this.data.listMonth > 1 && (this.setData({
      listMonth: this.data.listMonth - 1
    }), this.datelist())
  },
  nextDay: function (t) {
    var a = t.currentTarget.dataset.id;
    2 == a && this.data.listDay < 31 ? (this.setData({
      listDay: Number(this.data.listDay) + 1
    }), this.datelist()) : 4 == a && this.data.listMonth < 12 && (this.setData({
      listMonth: Number(this.data.listMonth) + 1
    }), this.datelist())
  },
  takeNote: function () {
    var t = this;
    t.datelist(),
      t.data.user[4] < 6 ? s.request({
        url: "https://www.qlsyyun.com:3030/maintain/page",
        data: {
          arr: 9,
          name: t.data.user[0]
        }
      }).then((function (a) {
        t.setData({
            pageDown: a.data[0].num
          }),
          s.request({
            url: "https://www.qlsyyun.com:3030/maintain",
            data: {
              arr: 9,
              total: t.data.total,
              name: t.data.user[0]
            }
          }).then((function (a) {
            t.setData({
              record: a.data
            })
          }))
      })) : 6 == t.data.user[4] ? s.request({
        url: "https://www.qlsyyun.com:3030/maintain/page",
        data: {
          arr: 11,
          bumen: t.data.user[1]
        }
      }).then((function (a) {
        t.setData({
            pageDown: a.data[0].num
          }),
          s.request({
            url: "https://www.qlsyyun.com:3030/maintain",
            data: {
              arr: 11,
              total: t.data.total,
              bumen: t.data.user[1]
            }
          }).then((function (a) {
            t.setData({
              record: a.data
            })
          }))
      })) : s.request({
        url: "https://www.qlsyyun.com:3030/maintain/page",
        data: {
          arr: 4
        }
      }).then((function (a) {
        t.setData({
            pageDown: a.data[0].num
          }),
          s.request({
            url: "https://www.qlsyyun.com:3030/maintain",
            data: {
              arr: 4,
              total: t.data.total
            }
          }).then((function (a) {
            t.setData({
              record: a.data
            })
            console.log(a.data)
          }))
      }))
  },
  contacts: function () {
    var t = this;
    t.data.user[4] < 6 ? s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 10,
        name: t.data.user[0]
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 10,
            total: t.data.total,
            name: t.data.user[0]
          }
        }).then((function (a) {
          t.setData({
            lists: a.data
          })
        }))
    })) : s.request({
      url: "https://www.qlsyyun.com:3030/maintain/page",
      data: {
        arr: 5
      }
    }).then((function (a) {
      t.setData({
          pageDown: a.data[0].num
        }),
        s.request({
          url: "https://www.qlsyyun.com:3030/maintain",
          data: {
            arr: 5,
            total: t.data.total
          }
        }).then((function (a) {
          t.setData({
            lists: a.data
          })
        }))
    }))
  },
  previousPage: function () {
    this.data.previousPage > 1 && (this.setData({
      total: this.data.total - 1,
      previousPage: this.data.total - 1
    }), 2 == this.data.id ? this.purpose() : 3 == this.data.id ? this.mycustom() : 4 == this.data.id ? this.stress() : 5 == this.data.id ? this.ocean() : 7 == this.data.id ? this.takeNote() : this.contacts(), wx.pageScrollTo({
      scrollTop: 0
    }))
  },
  pageDown: function () {
    this.data.previousPage < this.data.pageDown && (this.setData({
      total: this.data.total + 1,
      previousPage: this.data.total + 1
    }), 2 == this.data.id ? this.purpose() : 3 == this.data.id ? this.mycustom() : 4 == this.data.id ? this.stress() : 5 == this.data.id ? this.ocean() : 7 == this.data.id ? this.takeNote() : this.contacts(), wx.pageScrollTo({
      scrollTop: 0
    }))
  },
  customer: function (t) {
    var a = t.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/pages/record/search/search?id=" + a
    })
  },
  potential: function (t) {
    wx.navigateTo({
      url: "../more/more?id=" + t.currentTarget.dataset.id
    })
  },
  tailAfter: function (t) {
    var a = t.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/pages/record/followSea/followSea?id=" + a
    })
  }
});